<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" style="height: 100%">
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!--<link rel="stylesheet" th:href="@{all.min/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{all.min/style/admin.css}" media="all">-->
    <link rel="stylesheet" th:href="@{component/style/login.css}" media="all">
    <link rel="stylesheet" th:href="@{component/layui/css/layui.css}" media="all">
</head>
<style>
    /* 页脚 */
    footer {
        position: fixed;
        color: #e5e5e5;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        height: 20px;
        line-height: 20px;
    }

    body {
        background-attachment: fixed;
        background-color: white;
        background-position: center;
        background-repeat: no-repeat;
        background-size: auto;
        background-image: url('work/img/login_background_5.jpg');
    }
</style>

<body class="body">
<div class="admin-user-login admin-user-display-show" id="LAY-user-login">
    <div class="admin-user-login-main" style="background-color: white;">
        <div class="admin-user-login-box admin-user-login-header">
            <h2>平台管理系统</h2>
            <p>-------------------</p>
        </div>
        <div class="admin-user-login-box admin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="admin-user-login-icon layui-icon layui-icon-username"
                       for="LAY-user-login-username"></label>
                <input type="text" name="account" id="LAY-user-login-username" lay-verify="required" placeholder="用户名"
                       class="layui-input" value="admin">
            </div>
            <div class="layui-form-item">
                <label class="admin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input type="password" name="password" id="LAY-user-login-password" lay-verify="required"
                       placeholder="密码" class="layui-input" value="123456">
            </div>
            <div class="layui-form-item layui-hide" id="item-verBox">
                <div class="verBox">
                    <div id="imgVer" style="display:inline-block;"></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="admin-user-login-icon layui-icon layui-icon-vercode"
                               for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required"
                               placeholder="图形验证码" class="layui-input" value="">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img onclick="this.src='/getVerify?'+Math.random()" src="/getVerify" alt="验证码"
                                 class="admin-user-login-codeimg" id="LAY-user-get-vercode"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="margin-bottom: 20px;display: none;">
                <input type="checkbox" name="rememberMe" lay-skin="primary" title="记住密码">
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" id="but-sub" lay-submit lay-filter="LAY-user-login-submit">登
                    入
                </button>
            </div>
        </div>
    </div>
    <footer>© 2020 All Rights Reserved. MrDoubi</footer>
</div>
<script th:src="@{component/layui/layui.js?v=1.0.4}"></script>
<script th:src="@{work/js/md5.js}"></script>
<!--<script th:src="@{work/js/imgVer.js}"></script>-->
<script>
    layui.config({
        base: 'component/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'layer', 'jquery'], function () {
        if (self != top) {
            top.location = 'login';
        }
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;
        //监听提交
        form.on('submit(LAY-user-login-submit)', function (data) {
            //loading层
            var index = layer.load(2);
            data.field.password = hex_md5(data.field.password);
            $.post("login", data.field, function (res) {
                layer.close(index);
                if (res.code === 0) {
                    //登入成功的提示与跳转
                    layer.msg('登入成功', {
                        offset: '15px'
                        , icon: 1
                        , time: 1000
                    }, function () {
                        localStorage.clear();
                        location.href = res.data.link; //后台主页
                    });
                } else {
                    $("#get-vercode").trigger("click");
                    $("#login-vercode").val("");
                    layer.msg(res.msg);
                }
            });
        });
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode === 13) { // enter 键
                $("#but-sub").click();
            }
        };
    });

</script>
</body>
</html>